package br.dcc.ufmg.thresholds;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;


public class ThresholdsPropertiesLoader {
	
	private static Properties parameters;
	private static Map<String, String> properties;

	public static Map<String, String> getInstance() {
		if (properties == null) {
			try {
				openProperties();
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
			properties = new HashMap<String, String>();
			for (Object o : parameters.keySet()) {
				properties.put((String)o, parameters.getProperty((String)o));
			}
		}
		return properties;
	}

	public static void openProperties() throws IOException,
			FileNotFoundException {
		File file = new File("thresholds.properties");
		parameters = new Properties();
		if (file.exists()) {
			parameters.load(new FileInputStream(file));
		} else {
			System.out.println("Properties File not found");
			System.exit(0);
		}
	}
	

}
